<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background: url(images/1.jfif) no-repeat;
            background-size: 100% auto;
        }

        img {
            width: 100%;
            vertical-align: middle;
        }

        ul {
            width: 416px;
            height: 50px;
            text-align: center;
            margin: 200px auto;
        }

        li {
            width: 100px;
            float: left;
            list-style: none;
            margin: 2px;
        }
    </style>
</head>

<body>
    <ul class="baidu">
        <li><img src="images/1.jfif" alt=""></li>
        <li><img src="images/2.jfif" alt=""></li>
        <li><img src="images/3.jfif" alt=""></li>
        <li><img src="images/4.jfif" alt=""></li>
    </ul>
    <script>
        var imgs = document.querySelector('.baidu').querySelectorAll('img');
        for (let i = 0; i < imgs.length; i++) {
            imgs[i].onclick = function () {
                // console.log(imgs);
                // console.log(this.src);
                document.body.style.backgroundImage = 'url(' + this.src + ')';
            }
        }
    </script>
</body>

</html>